{$APPTYPE CONSOLE}
{$I-}
program MuLogGenModule;

uses
  SysUtils,
  Classes,
  MuUtils in 'MuUtils.pas',
  LogData in 'LogData.pas',
  LogErrors in 'LogErrors.pas',
  LogReader in 'LogReader.pas',
  LogSemantic in 'LogSemantic.pas',
  LogDelphi in 'LogDelphi.pas';

procedure Main();
var
  ErrorItems: TList;
  I: Integer;
begin
  if ParamCount = 0 then
  begin
    WriteLn('Usage MuLogGenModule.exe ModuleName');
    Exit;
  end;

  ErrorItems := TList.Create();
  try
    LogReader.DoIt(ParamStr(1), ErrorItems);
    LogSemantic.GenDefMethod(ErrorItems);

    if ErrorItems.Count = 0 then
    begin
      WriteLn('Generating pas...');
      GeneratePas();
    end
    else begin
      for I := 0 to ErrorItems.Count - 1 do
        WriteLn(FormatError(ErrorItems[I]));
    end;
  finally
    FreeObjectList(ErrorItems);
  end;
end;

begin
  ReportMemoryLeaksOnShutdown := True;
  Main();
end.